home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / beeper1.zip / BEEPER.ASM < prev    next >
Assembly Source File  |  1991-06-05  |  2KB  |  78 lines

  1. ; BEEPER.COM by Duane Paulson 06/05/91.
  2. ;  Beeps once a second until a key is pressed.
  3. ;  Created using comtemp.asm template by Chuck Nelson; (c) NELSOFT Software.
  4. ;  All rights reserved. Used by permission.
  5. ;  Comtemp.asm is included in The PC Assembler Helper and Tutor by
  6. ;  Chuck Nelson, downloadable as "PCTUTOR.xxx".
  7.  
  8. COMSEG  SEGMENT  PUBLIC  'CODE'
  9.  
  10.     ASSUME    cs:COMSEG, ds:COMSEG, es:COMSEG, ss:COMSEG
  11.  
  12. ORG    100h
  13.  
  14. main    proc    NEAR
  15.  
  16. start:    mov     ax,0E07h    ; TTY output - ascii 7 (beep)
  17.     mov    bh,0        ; primary video page
  18.     int    10h        ; call bios
  19.  
  20. main_loop:
  21.     mov    ah,0        ; get system timer
  22.     int    01Ah        ; call bios
  23.  
  24.                 ; system timer returns a double word (32 bits).
  25.                 ; since we're only waiting for one second,
  26.                 ; looking at the low word will suffice.
  27.  
  28.     add    dx,18        ; add 18 to low word (timer ticks 18 times/sec)
  29.     mov    low_timer,dx    ; store low word
  30.  
  31. wayt:    mov    ah,0Bh        ; check for character waiting
  32.     int    21h        ; call dos
  33.  
  34.     cmp    al,0FFh        ; character waiting?
  35.     je    clear_buffer    ;  then exit
  36.  
  37.     mov    ah,0        ; get system timer
  38.     int    01Ah        ; call bios
  39.  
  40.     cmp    dx,low_timer    ; compare low word to low_timer
  41.     jb    wayt        ; loop for 1 second
  42.  
  43.     mov     ax,0E07h    ; TTY output - ascii 7 (beep)
  44.     mov    bh,0        ; primary video page
  45.     mov    cx,1        ; display 1 character
  46.     int    10h        ; call bios
  47.  
  48.     mov    ah,0Bh        ; check for character waiting
  49.     int    21h        ; call dos
  50.  
  51.     cmp    al,0        ; no keypress?
  52.     je    main_loop    ;  then loop
  53.  
  54. clear_buffer:
  55.     mov    ah,7        ; Character input without echo
  56.     int    21h        ; call dos
  57.  
  58.     mov    ah,0Bh        ; check for character waiting
  59.     int    21h        ; call dos
  60.  
  61.     cmp    al,0FFh        ; character waiting?
  62.     je    clear_buffer    ;  then loop
  63.  
  64.     mov    ax,4C00h    ; exit with 0 exit code
  65.     int    21h        ; call dos and exit
  66.  
  67.     ret
  68.  
  69. main    endp
  70.  
  71. low_timer    dw    ?
  72.  
  73. COMSEG    ENDS
  74.  
  75. END    start
  76.  
  77.  
  78.